<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateMyWechatUploadTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    const TABLE_NAME = 'my_wechat_uploads';

    public function up()
    {
        Schema::create(self::TABLE_NAME, function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id');
            $table->char('openid', 64)->default('')->comment('openid');
            $table->tinyInteger('type', 0)->default(0)->comment('1-图片,2-视频');
            $table->integer('wechat_upload_id', false)->default(0)->comment('1-图片,2-视频');
            $table->dateTime('created_at')->nullable();
            $table->dateTime('updated_at')->nullable();
            $table->dateTime('deleted_at')->nullable();
            $table->index(['openid' ,'type', 'wechat_upload_id']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        if (Schema::hasTable(self::TABLE_NAME)) {
            Schema::drop(self::TABLE_NAME);
        }
    }
}
